package com.suixun.entity.page;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.suixun.entity.Factory;

public class PageModel<T> {
	// 当前页 第一条记录的索引 第1页的第1条记录索引为0
	private int startposition = 0;
	// 一页的记录数
	private int pagesize = 15;
	// 要查询的页码
	private int currentpage = 1;
	//总条数
	private int totlerows;
	//总页数
	private int totlepage;
	// 排序方式 asc desc
	private String sortorder = "desc";
	//查询参数
	private Map<String,Object> queryparam=new HashMap<String,Object>();
	//查询结果
	private List<T> queryresult;
	//所有生产厂商
	private List<Factory> factorys;
	//消息提醒
	private int warningrows;
	
	public int getStartposition() {
		return startposition;
	}
	public void setStartposition(int startposition) {
		this.startposition = startposition;
	}
	public int getPagesize() {
		return pagesize;
	}
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	public int getCurrentpage() {
		return currentpage;
	}
	public void setCurrentpage(int currentpage) {
		if(currentpage < 1) {
			this.currentpage = 1;
			startposition = 0;
		}else if(currentpage>totlepage){
			this.currentpage=totlepage;
			startposition=pagesize * (this.currentpage - 1);
		}else {
			this.currentpage = currentpage;
			startposition = pagesize * (currentpage - 1);
		}
		//如果查询totleRows为0的时候，startposition为负，这里进行调整
		if(startposition<0){
			startposition=0;
		}
	}
	public int getTotlepage() {
		return totlepage;
	}
	public void setTotlepage(int totleRows) {
		this.totlepage =totleRows%pagesize==0?totleRows/pagesize:totleRows/pagesize+1;
		this.totlerows=totleRows;
	}
	public String getSortorder() {
		return sortorder;
	}
	public void setSortorder(String sortorder) {
		this.sortorder = sortorder;
	}
	public Map<String, Object> getQueryparam() {
		return queryparam;
	}
	public void setQueryparam(Map<String, Object> queryparam) {
		this.queryparam = queryparam;
	}
	public List<T> getQueryresult() {
		return queryresult;
	}
	public void setQueryresult(List<T> queryresult) {
		this.queryresult = queryresult;
	}
	public int getTotlerows() {
		return totlerows;
	}
	public void setTotlerows(int totlerows) {
		this.totlerows = totlerows;
	}
	public List<Factory> getFactorys() {
		return factorys;
	}
	public void setFactorys(List<Factory> factorys) {
		this.factorys = factorys;
	}
	public int getWarningrows() {
		return warningrows;
	}
	public void setWarningrows(int warningrows) {
		this.warningrows = warningrows;
	}
	
	
	
	
}
